function throttle(func, wait, options) {
  let old = 0, timeOut
  return function () {
    options = options || {}
    let context = this, args = arguments
    // 时间戳
    let now = new Date().valueOf()
    if(options.leading===false){
      old = now
    }
    if (now - old > wait) {
      // 第一次触发
      if(timeOut){
        clearTimeout(timeOut)
        timeOut = null
      }
      func.apply(context, args)
      old = now
    }
    // setTimeout
    if (!timeOut && options.trailing!==false) {
      // 最后一次触发
      timeOut = setTimeout(() => {
        old = new Date().valueOf()
        timeOut = null
        func.apply(context, args)
      }, wait);
    }
  }
}